<%@page import="java.util.List"%>
<%@page import="entity.Book"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page errorPage="error.jsp" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" charset="utf-8" />
        <script src="js/jquery-3.4.1.min.js"></script>
        <script src="js/bootstrap.min.js"></script>
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
        <script scr="https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js"></script>
        <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
        <script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
        <script type="text/javascript">
            function check() {
                if (document.ff.keyword.value == "") {
                    alert("请输入图书信息！");
                    return false;
                }
                return true;
            }
        </script>
        <style>
            #a1:hover{
                color:#F90;
            }
            body{
                background: url(img/indexbg.jpg);
                background-size: cover;
            }
        </style>
    </head>
    <body>
        <div class="container">
            <h1 width="100px" style="margin-left: 10px">BookStore</h1>


            <div style="position:absolute;right: 20px;top:10px">
                <%
                    if (session.getAttribute("isLogin") == null) {
                %>
                <a href="Login.jsp" class="btn btn-success">登录</a>&nbsp;/&nbsp;<a href="Register.jsp" class="btn btn-primary">注册</a><br><br>
                <a href="AdminLogin.jsp" class="btn btn-danger">管理员登录</a>
                <%
                } else {
                    String name = (String) session.getAttribute("username");

                %>
                您好，<a href="Member.jsp?name=<%=name%>" style="text-decoration:none" id="a1"><%=name%></a><br>
                <a href="los" class="btn btn-warning">退出登录</a>
                <%
                    }
                %>
            </div>
            <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
                <!-- Indicators -->
                <ol class="carousel-indicators">
                    <li data-target="#carousel-example-generic" data-slide-to="0" class="active"><>
                    <li data-target="#carousel-example-generic" data-slide-to="1"><>
                    <li data-target="#carousel-example-generic" data-slide-to="2"><>
                    <li data-target="#carousel-example-generic" data-slide-to="3"><>
                </ol>

                <!-- Wrapper for slides -->
                <div class="carousel-inner" role="listbox">
                    <div class="item active">
                        <img src="img/1.jpg" alt="...">
                    </div>
                    <div class="item">
                        <img src="img/2.jpg" alt="...">
                    </div>
                    <div class="item">
                        <img src="img/3.jpg" alt="...">
                    </div>
                    <div class="item">
                        <img src="img/4.jpg" alt="...">
                    </div>
                </div>
                <!-- Controls -->
                <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
                    <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
                    <span class="sr-only">Previous</span>
                </a>
                <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
                    <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
                    <span class="sr-only">Next</span>
                </a>
            </div>
            <br>

            <form name="ff"   action="gbbn" onsubmit="return check()">
                <div class="col-lg-6">
                    <div class="input-group">
                        <input type="text" class="form-control" name="keyword" placeholder="请输入图书信息">
                        <span class="input-group-btn">
                            <button class="btn btn-success">搜索</button>
                        </span>
                    </div>
                </div>
            </form>


            <a href="gbbn?keyword=" class="btn btn-warning" >查看图书列表</a>
            <br>
            <hr>
            <%
                if (session.getAttribute("isLogin") == null) {
            %>
            <h3 style="margin-left: 10px">最新图书</h3>
            <div  style="width:1200px">
                <%
                    List<Book> list = (List<Book>) request.getAttribute("bookList");
                    for (int i = list.size() - 1; i >= 0 && i >= list.size() - 10; i--) {
                %>
                <div style="float:left;margin:10px 10px">
                    <a href="gbbi?id=<%=list.get(i).getId()%>" style="text-decoration:none" id="a1">
                        <img style="border-radius: 10px" src="img/<%=list.get(i).getCover()%>" width="220px" height="300px" alt="<%=list.get(i).getBookName()%>">

                        <p style="font-size:15px;margin-top: 10px"><%=list.get(i).getBookName()%></p>
                    </a>
                </div> 
                <%
                    }
                %>
            </div>
            <%
            } else {
            %>
            <h3 style="margin-left: 10px">推荐图书</h3>
            <div  style="width:1200px">
                <%
                    List<Book> list = (List<Book>) request.getAttribute("likelist");
                    for (int i = 0; i <= list.size() - 1 && i >= list.size() - 10; i++) {
                %>
                <div style="float:left;margin:10px 10px">
                    <a href="gbbi?id=<%=list.get(i).getId()%>" style="text-decoration:none" id="a1">
                        <img style="border-radius: 10px" src="img/<%=list.get(i).getCover()%>" width="220px" height="300px" alt="<%=list.get(i).getBookName()%>">
                        <p style="margin-top: 10px;font-size:15px"><%=list.get(i).getBookName()%></p>
                    </a>
                </div> 
                <%
                    }
                %>
            </div>

            <h3 style="clear: both;margin-left: 10px">最新图书</h3>
            <div  style="width:1200px">
                <%
                    List<Book> list1 = (List<Book>) request.getAttribute("bookList");
                    for (int i = list1.size() - 1; i >= 0 && i >= list.size() - 10; i--) {
                %>
                <div style="float:left;margin:10px 10px">
                    <a href="gbbi?id=<%=list1.get(i).getId()%>" style="text-decoration:none" id="a1">
                        <img style="border-radius: 10px"  src="img/<%=list1.get(i).getCover()%>" width="220px" height="300px" alt="<%=list1.get(i).getBookName()%>">
                        <p style="margin-top: 10px;font-size:15px"><%=list1.get(i).getBookName()%></p>
                    </a>
                </div> 
                <%
                    }
                %>
            </div>
            <%
                }
            %>
            <ul class="topicList">
                <li>
                    <div class="panel-heading" id="heading1">
                        <h4 class="panel-title">
                            <a role="button" data-toggle="collapse" data-parent="#accordion1" href="#collapse1A1"  class="btn btn-toolbar"style="text-decoration:none" id="a1">
                                <h4>科幻</h4>
                            </a>
                        </h4>
                    </div>
                    <div id="collapse1A1" class="panel-collapse collapse">
                        <div class="panel-body">
                            <div style="float:left;margin:10px 10px">
                                <a href="gbbi?id=5" style="text-decoration:none" id="a1">
                                    <img style="border-radius: 10px" src="img/image5.jpg" width="220px" height="300px" alt="三体">
                                    <p style="margin-top: 10px;font-size:15px">三体</p>
                                </a>
                            </div> 
                        </div>
                    </div>
                </li>
            </ul>
            <hr>
            <ul class="topicList">
                <li>
                    <div class="panel-heading" id="heading2">
                        <h4 class="panel-title">
                            <a role="button" data-toggle="collapse" data-parent="#accordion2" href="#collapse1A2"  class="btn btn-toolbar"style="text-decoration:none" id="a1">
                                <h4>人文社科</h4>
                            </a>
                        </h4>
                    </div>
                    <div id="collapse1A2" class="panel-collapse collapse">
                        <div class="panel-body">
                            <div style="float:left;margin:10px 10px">
                                <a href="gbbi?id=3" style="text-decoration:none" id="a1">
                                    <img style="border-radius: 10px" src="img/image3.jpg" width="220px" height="300px" alt="近代中国社会的新陈代谢">
                                    <p style="margin-top: 10px;font-size:15px">近代中国社会的新陈代谢</p>
                                </a>
                            </div> 
                        </div>
                    </div>
                </li>
            </ul>
            <hr>
            <ul class="topicList">
                <li>
                    <div class="panel-heading" id="heading3">
                        <h4 class="panel-title">
                            <a role="button" data-toggle="collapse" data-parent="#accordion3" href="#collapse1A3"  class="btn btn-toolbar"style="text-decoration:none" id="a1">
                                <h4>青春文学</h4>
                            </a>
                        </h4>
                    </div>
                    <div id="collapse1A3" class="panel-collapse collapse">
                        <div class="panel-body">
                            <div style="float:left;margin:10px 10px">
                                <a href="gbbi?id=4" style="text-decoration:none" id="a1">
                                    <img style="border-radius: 10px" src="img/1591533668.jpg" width="220px" height="300px" alt="小妖的金色城堡">
                                    <p style="margin-top: 10px;font-size:15px">小妖的金色城堡</p>
                                </a>
                            </div> 
                        </div>
                    </div>
                </li>
            </ul>
            <hr>
            <ul class="topicList">
                <li>
                    <div class="panel-heading" id="heading4">
                        <h4 class="panel-title">
                            <a role="button" data-toggle="collapse" data-parent="#accordion4" href="#collapse1A4"  class="btn btn-toolbar"style="text-decoration:none" id="a1">
                                <h4>名著</h4>
                            </a>
                        </h4>
                    </div>
                    <div id="collapse1A4" class="panel-collapse collapse">
                        <div class="panel-body">
                            <div style="float:left;margin:10px 10px">
                                <a href="gbbi?id=2" style="text-decoration:none" id="a1">
                                    <img style="border-radius: 10px" src="img/1590376726.jpg" width="220px" height="300px" alt="三国演义">
                                    <p style="margin-top: 10px;font-size:15px">三国演义</p>
                                </a>
                            </div> 
                        </div>
                    </div>
                </li>
            </ul>
            <hr>
            <ul class="topicList">
                <li>
                    <div class="panel-heading" id="heading5">
                        <h4 class="panel-title">
                            <a role="button" data-toggle="collapse" data-parent="#accordion5" href="#collapse1A5"  class="btn btn-toolbar"style="text-decoration:none" id="a1">
                                <h4>小说</h4>
                            </a>
                        </h4>
                    </div>
                    <div id="collapse1A5" class="panel-collapse collapse">
                        <div class="panel-body">
                            <div style="float:left;margin:10px 10px">
                                <a href="gbbi?id=5" style="text-decoration:none" id="a1">
                                    <img style="border-radius: 10px" src="img/image5.jpg" width="220px" height="300px" alt="三体">
                                    <p style="margin-top: 10px;font-size:15px">三体</p>
                                </a>
                            </div>
                            <div style="float:left;margin:10px 10px">
                                <a href="gbbi?id=2" style="text-decoration:none" id="a1">
                                    <img style="border-radius: 10px" src="img/1590376726.jpg" width="220px" height="300px" alt="三国演义">
                                    <p style="margin-top: 10px;font-size:15px">三国演义</p>
                                </a>
                            </div>
                            <div style="float:left;margin:10px 10px">
                                <a href="gbbi?id=1" style="text-decoration:none" id="a1">
                                    <img style="border-radius: 10px" src="img/1590376737.jpg" width="220px" height="300px" alt="战争与和平">
                                    <p style="margin-top: 10px;font-size:15px">战争与和平</p>
                                </a>
                            </div>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
        <div class="text-center " id="Foot" height="auto">	
            <footer>       
                <hr style="height:10px;border:none;border-top:10px groove skyblue;" />
                <center><em>&copy;</em>2020年著作权 冯秀起 张开翼 代乾宇 石鹏</center>        
                <center>未经上述开发者允许，本<font color="red">Jsp项目</font>的任何内容都不得以任何形式被复制、再传播，或篡改。</center>         
                <center>进入本<font color="red">jsp项目</font>后，即表示您同意遵守<font color="red">中华人民共和国网络安全法</font>。</center>
                <center>有任何的建议和意见，都欢迎联络我们：<font color="red">项目组长冯秀起先生</font></span</center>
            </footer>
            &nbsp;&nbsp;
        </div>
    </body>
</html>

